package cn.iocoder.yudao.module.vlog.info.vo;

import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
import cn.idev.excel.annotation.ExcelProperty;
import cn.iocoder.yudao.framework.business.basic.pojo.vo.UserSimpleVO;
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
import cn.iocoder.yudao.framework.region.RegionUtils;
import cn.iocoder.yudao.framework.region.vo.CityVO;
import cn.iocoder.yudao.framework.region.vo.setter.CityAutoSetter;
import cn.iocoder.yudao.module.api.product.spu.dto.ProductSpuRespDTO;
import cn.iocoder.yudao.module.api.shop.info.dto.ShopInfoDTO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Collection;

import static cn.iocoder.yudao.module.api.infrastructure.DictTypeConstants.BOOLEAN_STRING;
import static cn.iocoder.yudao.module.api.vlog.DictTypeConstants.VLOG_STATUS;

@Schema(description = "视频信息 Response VO")
@Data
@ExcelIgnoreUnannotated
public class VLogInfoRespVO extends CityVO implements CityAutoSetter {

    @Schema(description = "唯一编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "8137")
    @ExcelProperty("唯一编号")
    private Long id;

    @Schema(description = "店铺编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
    @ExcelProperty("店铺编号")
    private Long shopId;

    @Schema(description = "店铺信息")
    private ShopInfoDTO shop;

    @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
    @ExcelProperty("用户编号")
    private Long userId;

    private UserSimpleVO user;

    @Schema(description = "播放地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.example.com")
    @ExcelProperty("播放地址")
    private String playUrl;

    @Schema(description = "封面地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.example.com")
    @ExcelProperty("封面地址")
    private String coverUrl;

    @Schema(description = "视频标题")
    @ExcelProperty("视频标题")
    private String title;

    @Schema(description = "视频秒数")
    @ExcelProperty("视频秒数")
    private Integer seconds;

    @Schema(description = "视频宽度")
    @ExcelProperty("视频宽度")
    private Integer width;

    @Schema(description = "视频高度")
    @ExcelProperty("视频高度")
    private Integer height;

    @Schema(description = "视频大小")
    @ExcelProperty("视频大小")
    private Integer size;

    @Schema(description = "浏览数", example = "5676")
    @ExcelProperty("浏览数")
    private Integer browseCount;

    @Schema(description = "点赞数", example = "5676")
    @ExcelProperty("点赞数")
    private Integer likedCount;

    @Schema(description = "收藏数", example = "1427")
    @ExcelProperty("收藏数")
    private Integer favoriteCount;

    @Schema(description = "评论数", example = "18288")
    @ExcelProperty("评论数")
    private Long commentCount;

    @Schema(description = "分享数", example = "15699")
    @ExcelProperty("分享数")
    private Integer shareCount;

    @Schema(description = "是否私密", requiredMode = Schema.RequiredMode.REQUIRED)
    @ExcelProperty(value = "是否私密", converter = DictConvert.class)
    @DictFormat(BOOLEAN_STRING)
    private Boolean privacy;

    @Schema(description = "状态：0-待审核、1-展示中、2-已下架", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
    @ExcelProperty(value = "状态", converter = DictConvert.class)
    @DictFormat(VLOG_STATUS)
    private Integer status;

    @Schema(description = "行政区域省份编号", example = "52")
    private Integer provinceId;

    @Schema(description = "行政区域省份名称", example = "贵州省")
    private String provinceName;

    @Schema(description = "行政区域城市编号", example = "5201")
    private Integer cityId;

    @Schema(description = "行政区域城市名称", example = "贵阳市")
    private String cityName;

    @Schema(description = "纬度", example = "106.690801")
    private BigDecimal latitude;

    @Schema(description = "经度", example = "26.567322")
    private BigDecimal longitude;

    @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
    @ExcelProperty("创建时间")
    private LocalDateTime createTime;

    @Schema(description = "关联的产品列表")
    private Collection<ProductSpuRespDTO> spuList;

    @Override
    public String getCityCode() {
        return RegionUtils.convertRegionIdToCode(Math.toIntExact(this.cityId));
    }

    @Override
    public void setCityCode(String cityCode) {
        this.cityId = RegionUtils.convertRegionCodeToId(cityCode);
    }

    @Override
    public void setProvinceCode(String provinceCode) {
        this.provinceId = RegionUtils.convertRegionCodeToId(provinceCode);
    }

}
